<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<meta charset="UTF-8" />
<title>修改活码</title>
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1" />
<link href="http://layui.hcwl520.com.cn/layui-v2.4.5/css/layui.css?v=201811010202" rel="stylesheet"></link>
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  		<legend>修改用户</legend>
	</fieldset>
	<form class="layui-form"  >
				<div class="layui-form-item" >
					<label class="layui-form-label">邮箱</label>
					<div class="layui-input-block">
					 	<input type="hidden" th:value="${user.id}" id="id" name="id"> 
						<input type="text"  placeholder="请输入邮箱"
							autocomplete="off" class="layui-input" lay-verify="required|email" id="email" name="email" th:value="${user.email}" />
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">密码</label>
					<div class="layui-input-block">
						<input type="text"  placeholder="请输入密码"
							autocomplete="off" class="layui-input" lay-verify="required" id="password" name="password"  th:value="${user.password}"/>
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">是否为金主</label>
					 <div class="layui-input-block">
						 <input type="checkbox"  lay-filter="switchType"  lay-skin="switch" lay-text="金主|穷逼"  th:attr ="checked = ${user.type==2?true:false}">
						 <input type="hidden"  name="type" id="type" />
					</div>
				</div>
			    <div class="layui-input-block" style="display: none">
			      <button class="layui-btn" lay-submit="" lay-filter="edit" id="userSubmint" >立即提交</button>
			      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
   				 </div>
			</form>		
</body>
<script type="text/javascript" src="http://layui.hcwl520.com.cn/jquery/jquery-3.3.1.min.js?v=201804251754"></script>
<script type="text/javascript" src="http://layui.hcwl520.com.cn/layui-v2.4.5/layui.all.js?v=201811010202"></script>
<script th:inline="javascript">
$(function(){ 
	layui.use('form', function(){
		  var form = layui.form; 
		  form.on('switch(switchType)', function(data){
			  	if(!this.checked){
			  		$("#type").val(1);
			  	}else{
			  		$("#type").val(2);
			  	}
			  }); 
		  form.render();
		  form.on('submit(edit)', function(data){
		    $.ajax({
	            //几个参数需要注意一下
	                type: "POST",//方法类型
	                url: "editUser" ,//url
	                data: JSON.stringify(data.field),
	                contentType: 'application/json',
	                success: function (result) {
	                    if (result == "success") {
							parent.layer.msg('添加成功', {
								icon : 6,
							});
							parent.layer.closeAll('iframe'); 
	                    }else{
	                    	parent.layer.msg('出现网络故障', {
								icon : 5,
							});
							parent.layer.closeAll('iframe'); 
	                    }
	                },
	                error : function() {
	                    layer.alert("异常");
	                }
	            });
		      return false;
		  });
		});
		
	}); 
</script>
</html>

